<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>变量    {{ now }}</h1>
        <h1>计算属性  {{ mytime}}</h1>
    </div>
</body>
<script>

var vm = new Vue({
    el: "#app",
    data: {
       msg : 'heLLo',
       now : Date.now()  //当前时间
    },
    computed:{
        // 变大写
        uppermsg(){
            console.log( '正则运算....');
            return  this.msg.toUpperCase()
        },
        // 日期转换
        mytime(){
            let d = new Date( this.now )
            let y = d.getFullYear()
            let m = d.getMonth()+1
            let r = d.getDate()
            let h = d.getHours()
            let mm = d.getMinutes()
            let ss = d.getSeconds()
            return `${y}-${m}-${r} ${h}:${mm}:${ss}`
        }
    }
});

</script>
</html>